package edu.utn.tacs.grupouno.negocio;

import java.util.Collections;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import edu.utn.tacs.grupouno.dao.TurnoContainer;

public class DiaFactoryImpl implements DiaFactory {

	private TurnoContainer turnoContainer;
	
	public DiaFactoryImpl() {
	}
	
	@Override
	public Dia getDia(Date fecha) {
		Dia dia = new Dia(fecha);
		List<Turno> turnos = turnoContainer.getTurnosByDia(dia);
		Collections.sort(turnos, new TurnoHorarioComparator());
		dia.setTurnos(turnos);
		return dia;
	}

	@Override
	@Autowired
	public void setTurnoContainer(TurnoContainer turnoContainer) {
		this.turnoContainer = turnoContainer;
	}
	
	@Override
	public TurnoContainer getTurnoContainer() {
		return turnoContainer;
	}
	
}
